package com.dqhl.smartstable.util;

import android.app.Activity;
import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * Created by mac on 16/10/14.
 * 登录时发送验证码倒计时
 */
public class TimeCountLoginUtil extends CountDownTimer {

    private Activity mActivity;
    private TextView tv;

    public TimeCountLoginUtil(Activity mActivity, long millisInFuture, long countDownInterval, TextView tv) {
        super(millisInFuture, countDownInterval);
        this.mActivity = mActivity;
        this.tv = tv;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        String strSeconds = "剩余" + millisUntilFinished / 1000 + "秒";
        tv.setClickable(false);
        tv.setText(strSeconds);
    }

    @Override
    public void onFinish() {
        tv.setClickable(true);
        tv.setText("获取验证码");
    }
}
